import request from '@/utils/request'

// region table
export function addTable(data) {
  return request.post('admin/gen/table/addTable', data)
}

export function deleteTable(data) {
  return request.post('admin/gen/table/deleteTable', data)
}

export function editTable(data) {
  return request.post('admin/gen/table/editTable', data)
}

export function getTablePage(data) {
  return request.post('admin/gen/table/listPage', data)
}

// endregion table

// region field
export function addField(data) {
  return request.post('admin/gen/field/addField', data)
}

export function deleteField(data) {
  return request.post('admin/gen/field/deleteField', data)
}

export function editField(data) {
  return request.post('admin/gen/field/editField', data)
}

export function getFieldPage(data) {
  return request.post('admin/gen/field/listPage', data)
}

// endregion field

export function createCode(data) {
  return request.post('admin/gen/createCode?tableId=' + data.tableId + '&type=' + data.type)
}

export function createVue(data) {
  return request.post('admin/gen/createVue', data);
}

export function createFile(data) {
  return request.post('admin/gen/createFile?tableId=' + data.tableId + '&type=' + data.type)
}

export default {
  addTable,
  deleteTable,
  editTable,
  getTablePage,
  addField,
  deleteField,
  editField,
  getFieldPage,
  createCode,
  createFile
}
